package com.big.tree.config;


import org.apache.commons.lang3.StringUtils;

/**
 * @author big tree
 */
public class RoutingDataSourceContext {

    static final ThreadLocal<String> threadLocal = new ThreadLocal<>();

    public static String getDataSourceRoutingKey() {
        String key = threadLocal.get();
        return StringUtils.isEmpty(key) ? "master" : key;
    }

    public RoutingDataSourceContext(String key) {
        threadLocal.set(key);
    }

}
